<!DOCTYPE html>

<html lang="en">
<head>
	<meta charset="utf-8">
	<title>najaxjs Source: najax.static.js</title>

	<!--[if lt IE 9]>
	<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->
	<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">

	<link type="text/css" rel="stylesheet" href="styles/site.yeti.css">

</head>

<body>

<div class="navbar navbar-default navbar-fixed-top navbar-inverse">
<div class="container">
	<div class="navbar-header">
		<a class="navbar-brand" href="index.html">najaxjs</a>
		<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
        </button>
	</div>
	<div class="navbar-collapse collapse" id="topNavigation">
		<ul class="nav navbar-nav">
			
			<li class="dropdown">
				<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b class="caret"></b></a>
				<ul class="dropdown-menu ">
					<li><a href="$najax.html">$najax</a></li><li><a href="$najax.define.html">$najax.define</a></li><li><a href="$najax.history.html">$najax.history</a></li><li><a href="$najax@class.html">$najax@class</a></li><li><a href="$najax@ex.html">$najax@ex</a></li><li><a href="$najax@helper.html">$najax@helper</a></li><li><a href="$najax@read.html">$najax@read</a></li><li><a href="$najax@rlk.html">$najax@rlk</a></li>
				</ul>
			</li>
			
			<li class="dropdown">
				<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b class="caret"></b></a>
				<ul class="dropdown-menu ">
					<li><a href="Linker.html">Linker</a></li><li><a href="Nx.html">Nx</a></li><li><a href="Pager.html">Pager</a></li><li><a href="Reflector.html">Reflector</a></li><li><a href="Relay.html">Relay</a></li><li><a href="RESTful.html">RESTful</a></li><li><a href="Singular.html">Singular</a></li><li><a href="Tx.html">Tx</a></li>
				</ul>
			</li>
			
			<li class="dropdown">
				<a href="tutorials.list.html" class="dropdown-toggle" data-toggle="dropdown">Tutorials<b class="caret"></b></a>
				<ul class="dropdown-menu ">
					<li><a href="tutorial-demo-ui-ajax.html">demo-ui-ajax</a></li><li><a href="tutorial-najax-class.html">najax-class</a></li><li><a href="tutorial-najax-ex.html">najax-ex</a></li><li><a href="tutorial-najax-helper.html">najax-helper</a></li><li><a href="tutorial-najax-read.html">najax-read</a></li><li><a href="tutorial-relaylinker.html">relaylinker</a></li><li><a href="tutorial-rlk-standalone.html">rlk-standalone</a></li><li><a href="tutorial-static-history.html">static-history</a></li><li><a href="tutorial-static-najax-micro.html">static-najax-micro</a></li><li><a href="tutorial-static-najax.html">static-najax</a></li>
				</ul>
			</li>
			
			<li class="dropdown">
				<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a>
				<ul class="dropdown-menu ">
					<li><a href="global.html">Global</a></li>
				</ul>
			</li>
			
		</ul>
		<div class="col-sm-3 col-md-3">
            <form class="navbar-form" role="search">
                <div class="input-group">
                    <input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
                    <div class="input-group-btn">
                        <button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
                    </div>
                </div>
            </form>
        </div>
	</div>

</div>
</div>


<div class="container" id="toc-content">
<div class="row">

	
	<div class="col-md-12">
	
		<div id="main">
			

		<h1 class="page-title">Source: najax.static.js</h1>
    
<section>
    <article>
        <pre
            class="sunlight-highlight-javascript linenums">'use strict';

/**
 * $najax(any-ajax) static methods. Provide various ajax methods.
 *
 * | Method | Default ver | Tiny ver |
 * |:---|:---:|:---:|
 * | scriptTag | Yes | - |
 * | jsonpTag | Yes | - |
 * | Others | Yes | Yes |
 *
 * &lt;b>Requires&lt;/b>&lt;br>
 * Any other library is unnecessary.
 * &lt;small>(Only $najax.sendex method requires &lt;i>any.js&lt;/i> and &lt;i>jQuery&lt;/i> library.)&lt;/small>
 *
 * &lt;b>Specification&lt;/b>&lt;br>
 * - Specify ajax request and response behaviors by &lt;code>Nx object&lt;/code>.
 * - Specify by Nx object's various method or &lt;code>Nx &lt;i>opt&lt;/i>&lt;/code> method.
 * - Begin ajax connection by &lt;code>Nx &lt;i>done&lt;/i>&lt;/code>.
 * - &lt;code>Nx &lt;i>done&lt;/i>&lt;/code> returns &lt;code>Relay object&lt;/code>.
 * - &lt;code>Relay&lt;/code> provide operating response-data, and bundling multiple &lt;code>Relay&lt;/code>.
 * - &lt;code>Nx&lt;/code> implement ajax by using &lt;i>XMLHttpRequest&lt;/i>.
 *
 * @namespace $najax
 *
 * @see $najax.request
 *
 * @tutorial static-najax
 *
 * @example
 * $najax.request('path.php').done();
 * $najax.request('path.php', {a1:1,a2:2,a3:3}).done(function(data){ ... });
 *
 * $najax.post('path.php', {a:1, b:2, c:3}).done();
 * $najax.post('path.php').param('a', 'A').param('b', 'B').done();
 * $najax.raw('path.php').done();
 *
 * $najax.html('template.htm').done(function(el){ ... });
 * $najax.xml('xml.php').done(function(xml){ ... });
 * $najax.jsonp('jsonp.php', jsp_func).done();
 * $najax.sync('ajax.php').done(function(data){ ... });
 * $najax.script('script.php').done();
 * $najax.csv('list.csv').done(function(rows){ ... });
 */

/**
 * Simple ajax request. It's possible to specify ajax behaviors by using Nx object's method chaining.
 *
 * @function request
 * @memberof $najax
 *
 * @param {string} url URL.
 * @param {assoc} [vs=null] Parameters for GET / POST.
 * @param {assoc} [opt] Nx options.
 * @returns {Nx}
 *
 * @see $najax.get
 * @see $najax.post
 *
 * @see Nx
 * @see Relay
 *
 * @tutorial static-najax
 *
 * @example
 * $najax.request('path.php').done();
 * $najax.request('path.php', {a1:1,a2:2,a3:3}).done(function(data){ ... });
 * var nx = $najax.request('path.php');nx.param('a', 1).done();
 * $najax.request('path.php').type('raw').done();
 * $najax.request('path.php').success(function(){ ... }).fail(function(){ ... }).done();
 * $najax.request('path.php').retry(2).done();
 * $najax.request('path.php').async(false).timeout(30).done();
 * $najax.request('path.php').header('certify', 'mycode').done();
 * $najax.request('path.php').upload(element).done();
 * $najax.request('path.php').running(function(v){ ... }).complete(function(){ ... }).done();
 */
njx.request = function(url, vs, opt){
	return (new Nx(opt)).__basic(url , vs);
};

/**
 * GET ajax request.
 * @function get
 * @memberof $najax
 *
 * @param {string} url URL.
 * @param {assoc} [vs=null] Parameters for GET.
 * @param {assoc} [opt] Nx options.
 * @returns {Nx}
 *
 * @see Nx
 * @see Relay
 * @see Linker
 * @see $najax.request
 * @see $najax.post
 *
 * @tutorial static-najax
 * @example
 * $najax.get('path.php').done();
 * $najax.get('path.php', {a1:1,a2:2,a3:3}).done(function(data){ ... });
 */
njx.get = function(url, vs, opt){
	return (new Nx(opt)).__basic(url , vs).opt('method', 'GET');
};

/**
 * POST ajax request.
 * @function post
 * @memberof $najax
 *
 * @param {string} url URL.
 * @param {assoc} [vs=null] Parameters for POST.
 * @param {assoc} [opt] Nx options.
 * @returns {Nx}
 *
 * @see Nx
 * @see Relay
 * @see $najax.request
 * @see $najax.get
 *
 * @tutorial static-najax
 * @example
 * $najax.post('path.php', {a:1, b:2, c:3}).done();
 * $najax.post('path.php').param('a', 'A').param('b', 'B').done();
 * $najax.post('path.php', vs).done(function(data){ ... });
 */
njx.post = function(url, vs, opt){
	return (new Nx(opt)).__basic(url , vs).opt('method', 'POST');
};

/**
 * Raw(text) response / ajax request.
 * @function raw
 * @memberof $najax
 *
 * @param {string} url URL.
 * @param {assoc} [vs=null] Parameters for GET / POST.
 * @param {assoc} [opt] Nx options.
 * @returns {Nx}
 *
 * @see Nx
 * @see Relay
 * @see $najax.request
 *
 * @tutorial static-najax
 * @example
 * $najax.raw('path.php').done();
 * $najax.raw('path.php', vs).done(function(data){ ... });
 * $najax.raw('path.php', vs).success(function(raw){ ... }).done();
 */
njx.raw = function(url, vs, opt){
	return (new Nx(opt)).__basic(url , vs).type('raw');
};

/**
 * Alias of $najax.raw.
 * @function text
 * @memberof $najax
 *
 * @param {string} url URL.
 * @param {assoc} [vs=null] Parameters for GET / POST.
 * @param {assoc} [opt] Nx options.
 * @returns {Nx}
 *
 * @see Nx
 * @see Relay
 * @see $najax.request
 *
 * @tutorial static-najax
 * @example
 * $najax.text('path.php').done();
 * $najax.text('path.php', vs).done(function(data){ ... });
 * $najax.text('path.php').success(function(text){ ... }).done();
 */
njx.text = function(url, vs, opt){
	return njx.raw(url, vs, opt);
};

/**
 * HTML response / ajax request. This method evaluate JavaScript in HTML. It's possible to specify root element by &lt;code>element&lt;/code> option in Nx.
 *
 * &lt;b>Response value type&lt;/b> &lt;code>Element&lt;/code>
 *
 * @function html
 * @memberof $najax
 *
 * @param {string} url URL.
 * @param {assoc} [vs=null] Parameters for GET / POST.
 * @param {assoc} [opt] Nx options.
 * @param {boolean} [opt.cache=true] Enable cache.
 * @returns {Nx}
 *
 * @see Nx
 * @see Relay
 * @see $najax.request
 *
 * @tutorial static-najax
 * @example
 * $najax.html('template.htm').done(function(el){ ... }); //Response arg is Element.
 * $najax.html('template.php').success(function(el){ ... }).done();
 * $najax.html('template.php').opt('element', 'span').(function(el){ ... }).done();  //root element tag.
 * $najax.html('template.php').opt('element', el).(function(el){ ... }).done();			//root element.
 */
njx.html = function(url, vs, opt){
	return (new Nx(opt)).__basic(url , vs).cache(true).type('html');
};

/**
 * Script execute / ajax request. It's possible to specify evaluate mode, &lt;i>eval&lt;/i> or &lt;i>function&lt;/i> by &lt;code>iseval&lt;/code> option in Nx.
 *
 * &lt;b>Response value type&lt;/b> &lt;code>null&lt;/code>
 *
 * @function script
 * @memberof $najax
 *
 * @param {string} url URL.
 * @param {assoc} [vs=null] Parameters for GET / POST.
 * @param {assoc} [opt] Nx options.
 * @param {boolean} [opt.cache=true] Enable cache.
 * @returns {Nx}
 *
 * @see Nx
 * @see Relay
 * @see $najax.request
 *
 * @tutorial static-najax
 * @example
 * $najax.script('script.php').done();
 * $najax.script('script.php').opt('iseval', false).done();	//by function.
 */
njx.script = function(url, vs, opt){
	return (new Nx(opt)).__basic(url , vs).cache(true).type('script');
};

/**
 * Function response / ajax request. This method don't execute script, pass &lt;i>function object&lt;/i> to argument.
 *
 * &lt;b>Response value type&lt;/b> &lt;code>function&lt;/code>
 *
 * @function func
 * @memberof $najax
 *
 * @param {string} url URL.
 * @param {assoc} [vs=null] Parameters for GET / POST.
 * @param {assoc} [opt] Nx options.
 * @param {boolean} [opt.cache=true] Enable cache.
 * @returns {Nx}
 *
 * @see Nx
 * @see Relay
 * @see $najax.request
 *
 * @tutorial static-najax
 * @example
 * $najax.func('script.php').done(function(fn){ ... });
 * $najax.func('script.php').success(function(fn){ ... }).done();
 */
njx.func = function(url, vs, opt){
	return (new Nx(opt)).__basic(url, vs).cache(true).type('func');
};

/**
 * XML response / ajax request.
 *
 * &lt;b>Response value type&lt;/b> &lt;code>XMLDocument&lt;/code>
 *
 * @function xml
 * @memberof $najax
 *
 * @param {string} url URL.
 * @param {assoc} [vs=null] Parameters for GET / POST.
 * @param {assoc} [opt] Nx options.
 * @returns {Nx}
 *
 * @see Nx
 * @see Relay
 * @see $najax.request
 *
 * @tutorial static-najax
 * @example
 * $najax.xml('xml.php').done(function(xml){ ... });
 * $najax.xml('xml.php', vs).done(function(xml){ ... });
 * $najax.xml('xml.php').param({a:1, b:1, c:3}).done(function(xml){ ... });
 */
njx.xml = function(url, vs, opt){
	return (new Nx(opt)).__basic(url , vs).type('xml');
};

/**
 * Jsonp / ajax request. It's possible to specify jsonp-callback function by &lt;code>jsonp&lt;/code> func in Nx.
 *
 * &lt;b>Response value type&lt;/b> &lt;code>null&lt;/code>
 *
 * @function jsonp
 * @memberof $najax
 *
 * @param {string} url URL.
 * @param {function|string} fn Callback function. It must be global function.
 * @param {assoc} [opt] Nx options.
 * @returns {Nx}
 *
 * @see Nx
 * @see Relay
 * @see $najax.request
 *
 * @tutorial static-najax
 * @example
 * $najax.jsonp('jsonp.php', jsp_func).done();
 * $najax.jsonp('jsonp.php', 'jsp_func').done();
 * $najax.jsonp('jsonp.php', jsp_func).method('post').done();
 * $najax.jsonp('jsonp.php').jsonp(jsp_func, 'callback').param(vs).done();
 */
njx.jsonp = function(url, fn, opt){
	return (new Nx(opt)).__basic(url).jsonp(fn);
};

/**
 * CSV(TSV) response / ajax request. It's possible to specify csv-separator by &lt;code>separator&lt;/code> option in Nx.
 *
 * &lt;b>Response value type&lt;/b> &lt;code>Array&lt;/code>
 *
 * @function csv
 * @memberof $najax
 *
 * @param {string} url URL.
 * @param {assoc} [vs=null] Parameters for GET / POST.
 * @param {assoc} [opt] Nx options.
 * @returns {Nx}
 *
 * @see Nx
 * @see Relay
 * @see $najax.request
 *
 * @tutorial static-najax
 * @example
 * $najax.csv('list.csv').done(function(rows){ ... });
 * $najax.csv('list.tsv').opt('separator', "\t").done(function(rows){ ... });
 */
njx.csv = function(url, vs, opt){
	return (new Nx(opt)).__basic(url , vs).type('csv');
};

/**
 * Ajax request with synchronization mode.
 *
 * @function sync
 * @memberof $najax
 *
 * @param {string} url URL.
 * @param {assoc} [vs=null] Parameters for GET / POST.
 * @param {assoc} [opt] Nx options.
 * @returns {Nx}
 *
 * @see Nx
 * @see Relay
 * @see $najax.request
 *
 * @tutorial static-najax
 * @example
 * $najax.sync('ajax.php').done(function(data){ ... });
 * var rl = $najax.sync('ajax.php').done();
 * var v = rl.value();
 */
njx.sync = function(url, vs, opt){
	return (new Nx(opt)).__basic(url , vs).async(false);
};
</pre>
    </article>
</section>





		</div>
	</div>

	<div class="clearfix"></div>

	

</div>
</div>

<div class="modal fade" id="searchResults">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">Search results</h4>
      </div>
      <div class="modal-body"></div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div>

<footer>

	&nbsp;


<span class="jsdoc-message">
	Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a>
	
	using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
</footer>

<script src="scripts/docstrap.lib.js"></script>
<script src="scripts/toc.js"></script>
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>

<script>
$( function () {
	$( "[id*='$']" ).each( function () {
		var $this = $( this );

		$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
	} );

	$( ".tutorial-section pre, .readme-section pre" ).each( function () {
		var $this = $( this );

		var example = $this.find( "code" );
		exampleText = example.html();
		var lang = /{@lang (.*?)}/.exec( exampleText );
		if ( lang && lang[1] ) {
			exampleText = exampleText.replace( lang[0], "" );
			example.html( exampleText );
			lang = lang[1];
		} else {
			var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
			lang = langClassMatch ? langClassMatch[1] : "javascript";
		}

		if ( lang ) {

			$this
			.addClass( "sunlight-highlight-" + lang )
			.addClass( "linenums" )
			.html( example.html() );

		}
	} );

	Sunlight.highlightAll( {
		lineNumbers : true,
		showMenu : true,
		enableDoclinks : true
	} );

	$.catchAnchorLinks( {
        navbarOffset: 10
	} );
	$( "#toc" ).toc( {
		anchorName  : function ( i, heading, prefix ) {
			var id = $( heading ).attr( "id" );
			return id && id.replace(/\~/g, '-inner-').replace(/\./g, '-static-') || ( prefix + i );
		},
		selectors   : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
		showAndHide : false,
		smoothScrolling: true
	} );

	$( "#main span[id^='toc']" ).addClass( "toc-shim" );
	$( '.dropdown-toggle' ).dropdown();

    $( "table" ).each( function () {
      var $this = $( this );
      $this.addClass('table');
    } );

} );
</script>



<!--Navigation and Symbol Display-->


<!--Google Analytics-->


<script type="text/javascript">
	$(document).ready(function() {
		SearcherDisplay.init();
	});
</script>

</body>
</html>
